<template>
  <div class="auto" style="margin-top: 10px;border: 1px solid #F2F6FA;">
    <criteria v-ref:criteria>
      <div novalidate class="form-horizontal" partial>
        <p class="flex-between bg-info" style="padding: 8px;">
          <span>表具查询</span>
          <span class="btn btn-link add-postition" @click="$parent.clear()">清空查询条件</span>
        </p>
        <div class="form-group">
          <label class=" col-sm-3 control-label">表编号</label>
          <div class="col-sm-9">
            <input type="text" class="form-control" v-model="model.f_user_id"
            condition="all_表编号_11 = '{}'" placeholder='表编号'
            :size="model.f_user_id ? model.f_user_id.length : 1">
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气价名称</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_price_name"
                v-model="model.f_price_name"
                :options='$parent.pricenames' placeholder='请选择'
                condition="all_气价名称_12= '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气表分类</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_meter_classify"
                v-model="model.f_meter_classify"
                :options='$parent.metertypes' placeholder='请选择'
                condition="all_气表分类_15 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气表品牌</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_meter_brand"
                v-model="model.f_meter_brand"
                :options='$parent.meterbrands' placeholder='请选择'
                condition="all_气表品牌_13 = '{}'"
                close-on-select></v-select>
            </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气表型号</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_meter_model"
                v-model="model.f_meter_model"
                :options='$parent.meterstyles' placeholder='请选择'
                condition="all_气表型号_20 = '{}'"
                close-on-select></v-select>
            </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">表号</label>
          <div class="col-sm-9">
            <input  type="text" class="form-control" v-model="model.f_meternumber"
            condition="all_气表表号_14 like '%{}%'" placeholder='表号'
            :size="model.f_meternumber ? model.f_meternumber.length : 1">
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">卡号</label>
          <div class="col-sm-9">
            <input  type="text" class="form-control" v-model="model.f_card_id"
            condition="all_卡号_17 like '%{}%'" placeholder='卡号'
            :size="model.f_card_id ? model.f_card_id.length : 1">
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">气表状态 </label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_table_state"
                v-model="model.f_table_state"
                :options='$parent.tablestate' placeholder='请选择'
                condition="all_表状态_19 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
      </div>
    </criteria>
  </div>
</template>

<script>
import AppData from '../../../../stores/AppData'
export default {
  title: '表具查询条件',
  methods: {
    getArgs () {
      return this.$refs.criteria.search()
    },
    // 清空所有查询条件
    clear () {
      Object.keys(this.$refs.criteria.model).forEach((key) => {
        this.$refs.criteria.model[key] = ''
      })
    }
  },
  computed: {
    metertypes () {
      return [{label: '全部', value: ''}, ...AppData.getParam('气表类型')]
    },
    meterbrands () {
      let arr = []
      AppData.getGasbrand().forEach((item) => {
        let temp = {}
        temp.label = item.label
        temp.value = item.value.f_meter_brand
        arr.push(temp)
      })
      return [{label: '全部', value: ''}, ...arr]
    },
    meterstyles () {
      return [{label: '全部', value: ''}, ...AppData.getParam('气表型号')]
    },
    pricenames () {
      let arr = []
      AppData.getOnlyPrice().forEach((item) => {
        let temp = {}
        temp.label = item.label
        temp.value = item.value.f_price_name
        arr.push(temp)
      })
      return [{label: '全部', value: ''}, ...arr]
    },
    tablestate () {
      return [{label: '全部', value: ''}, {label: '正常', value: '正常'}, {label: '停用', value: '停用'}]
    }
  }
}
</script>
